import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ItemData } from "../../resource/info/ItemData";
import { Global } from "../../../../com/gengine/global/Global";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../resource/ColorConfig";
import { ELotteryCategory } from "../../../../Message/Public/ELotteryCategory";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { SWFPlayer } from "../../scene/modle/SWFPlayer";
import { StaticResUrl } from "../../resource/StaticResUrl";
import { ModelType } from "../../scene/modle/data/ModelType";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { BaseItem } from "../common/BaseItem";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ActionType } from "../../scene/modle/data/ActionType";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { _newPrice } from "../../../../this/_newPrice";
import { _index } from "../../../../this/_index";
type int = number;
//class DramaLotteryRender
    
    export  class DramaLotteryRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this._oIngot = new Object /* flash.display.Bitmap */();
            this._pIngot = new Object /* flash.display.Bitmap */();
            this.initView();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            super.data = arg1;
            this._itemCode = arg1.itemCode as int;
            this._oldPrice = arg1.oldPrice as int;
            this._newPrice = arg1.newPrice as int;
            this._index = arg1.index as int;
            this._category = arg1.category as int;
            if (this._itemCode > 0) 
            {
                this.visible = true;
                this._itemData = new ItemData(this._itemCode);
                if (this._itemData) 
                {
                    if (Global.isDebugModle) 
                    {
                        this._debugShow.text = this._category.toString();
                    }
                    this._propItem.itemData = this._itemData;
                    this._oPriceNumLabel.htmlText = HTMLUtil.addColor(this._oldPrice.toString(), "#F4FF01");
                    this._oPriceNumLabel.drawNow();
                    this._redLine.graphics.lineStyle(2, 16711680, 0.75);
                    this._redLine.graphics.moveTo(122, 44);
                    this._redLine.graphics.lineTo(154, 57);
                    this._pPriceNumLabel.htmlText = HTMLUtil.addColor(this._newPrice.toString(), "#F4FF01");
                    this._pPriceNumLabel.drawNow();
                    loc1 = ColorConfig.instance.getItemColor(this._itemData.itemInfo.item.color);
                    if (loc1) 
                    {
                        loc2 = loc1.color;
                    }
                    this._nameLabel.htmlText = HTMLUtil.addColor(this._itemData.itemInfo.item.name, loc2);
                    if (this._category != ELotteryCategory._ELotteryCommon) 
                    {
                        if (this._category == ELotteryCategory._ELotterySpecial || this._category == ELotteryCategory._ELotterySpecialTwo) 
                        {
                            this._luckTx.htmlText = Language.getString(70684);
                        }
                        else if (this._category == ELotteryCategory._ELotteryPrivilege || this._category == ELotteryCategory._ELotterySmallSurpirse || this._category == ELotteryCategory._ELotteryBigSurprise) 
                        {
                            this._luckTx.htmlText = Language.getString(70683);
                        }
                        else if (this._category != ELotteryCategory._ELotteryFress) 
                        {
                            if (this._category == ELotteryCategory._ELotteryActive) 
                            {
                                this._luckTx.htmlText = Language.getString(70686);
                            }
                        }
                        else 
                        {
                            this._luckTx.htmlText = Language.getString(70685);
                        }
                    }
                    else 
                    {
                        this._luckTx.htmlText = Language.getString(70682);
                    }
                    if (this._category == ELotteryCategory._ELotterySpecial || this._category == ELotteryCategory._ELotterySpecialTwo) 
                    {
                        this.drawLine(GlobalStyle.color4Uint);
                        if (!this._swfPlayer) 
                        {
                            this._swfPlayer = new SWFPlayer();
                            this._swfPlayer.timeRate = 1;
                        }
                        addChild(this._swfPlayer);
                        this._swfPlayer.loadComplete = this.onArrowLoaded;
                        this._swfPlayer.load(StaticResUrl.DramaLotteryBuySpecial, ModelType.NormalSwf, null);
                    }
                    else if (this._category != ELotteryCategory._ELotteryFress) 
                    {
                        if (this._category != ELotteryCategory._ELotteryActive) 
                        {
                            this._selectLine.graphics.clear();
                            if (this._swfPlayer) 
                            {
                                this._swfPlayer.dispose();
                            }
                        }
                        else 
                        {
                            this.drawLine(16750848);
                            if (!this._swfPlayer) 
                            {
                                this._swfPlayer = new SWFPlayer();
                                this._swfPlayer.timeRate = 1;
                            }
                            addChild(this._swfPlayer);
                            this._swfPlayer.loadComplete = this.onArrowLoaded;
                            this._swfPlayer.load(StaticResUrl.DramaLotteryBuySpecial, ModelType.NormalSwf, null);
                        }
                    }
                    else 
                    {
                        this.drawLine(GlobalStyle.color8Uint);
                        if (!this._swfPlayer) 
                        {
                            this._swfPlayer = new SWFPlayer();
                            this._swfPlayer.timeRate = 1;
                        }
                        addChild(this._swfPlayer);
                        this._swfPlayer.loadComplete = this.onArrowLoaded;
                        this._swfPlayer.load(StaticResUrl.DramaLotteryBuySpecial, ModelType.NormalSwf, null);
                    }
                }
            }
            else 
            {
                this.visible = false;
            }
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            this._bg = ObjCreate.createBg(0, 23, 198, 84, this, ImagesConst.DisabledBg);
            this._itemBg = GlobalClass.getBitmap("PropBg");
            this._itemBg.x = 5;
            this._itemBg.y = 31;
            this.addChild(this._itemBg);
            this._propItem = new BaseItem();
            this._propItem.isDragAble = false;
            this._propItem.label = "";
            this._propItem.setSize(60, 60);
            this._propItem.move(9, 35);
            this.addChild(this._propItem);
            this._nameLabel = new GLabel();
            this._nameLabel.x = 81;
            this._nameLabel.y = 24;
            this._nameLabel.autoSize = flash.text.TextFormatAlign.LEFT;
            this.addChild(this._nameLabel);
            this._oPriceLabel = new GLabel();
            this._oPriceLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._oPriceLabel.htmlText = HTMLUtil.addColor(Language.getString(53013), "#B0EFFF");
            this._oPriceLabel.x = 81;
            this._oPriceLabel.y = 43;
            this.addChild(this._oPriceLabel);
            this._oPriceNumLabel = new GLabel();
            this._oPriceNumLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._oPriceNumLabel.x = 125;
            this._oPriceNumLabel.y = 43;
            this.addChild(this._oPriceNumLabel);
            this._oIngot = new Object /* flash.display.Bitmap */();
            this._oIngot.x = 153;
            this._oIngot.y = 39;
            this.addChild(this._oIngot);
            this._pIngot = new Object /* flash.display.Bitmap */();
            this._pIngot.x = 153;
            this._pIngot.y = 56;
            this.addChild(this._pIngot);
            this._redLine = new Object /* flash.display.Shape */();
            this.addChild(this._redLine);
            this._pPriceLabel = new GLabel();
            this._pPriceLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._pPriceLabel.htmlText = HTMLUtil.addColor(Language.getString(53014), "#00FF1F");
            this._pPriceLabel.x = 81;
            this._pPriceLabel.y = 62;
            this.addChild(this._pPriceLabel);
            this._pPriceNumLabel = new GLabel();
            this._pPriceNumLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._pPriceNumLabel.x = 125;
            this._pPriceNumLabel.y = 62;
            this.addChild(this._pPriceNumLabel);
            this._buyBtn = new GButton();
            this._buyBtn.label = Language.getString(53016);
            this._buyBtn.styleName = "Button";
            this._buyBtn.setSize(44, 22);
            this._buyBtn.move(117, 80);
            this._buyBtn.drawNow();
            this._buyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBuyBtnClickhandler);
            this.addChild(this._buyBtn);
            this._selectLine = new Object /* flash.display.Sprite */();
            this._selectLine.y = 23;
            this._selectLine.mouseEnabled = false;
            this.addChild(this._selectLine);
            loc1 = GlobalClass.getBitmap("Yuanbao");
            loc1.x = 159;
            loc1.y = 44;
            this.addChild(loc1);
            var loc2=GlobalClass.getBitmap("Yuanbao");
            loc2.x = 159;
            loc2.y = 62;
            this.addChild(loc2);
            this._debugShow = ObjCreate.createTextField("", 5, 20, 50, 20, this, GlobalStyle.textFormat2);
            var loc3=ObjCreate.createBg(38, 0, 140, 22, this, ImagesConst.SelectedBg);
            this._luckTx = ObjCreate.createTextField("", 0, 0, width, 20, this, new GTextFormat(FontUtil.songtiName, 15, 16750848, true));
            this._luckTx.autoSize = flash.text.TextFormatAlign.CENTER;
            return;
        }

        /* internal  */onArrowLoaded(arg1: SWFPlayer): void
        {
            this._swfPlayer.updateFrame(ActionType.Stand, 1, true);
            this._swfPlayer.updateCurrentFrame(0);
            this._swfPlayer.play();
            this._swfPlayer.sceneX = 40;
            this._swfPlayer.sceneY = 62;
            return;
        }

        /* internal  */drawLine(arg1: uint): void
        {
            this._selectLine.graphics.clear();
            this._selectLine.graphics.lineStyle(3, arg1, 1);
            this._selectLine.graphics.drawRoundRect(1, 0, this._bg.width - 2, this._bg.height - 2, 4, 4);
            this._selectLine.graphics.endFill();
            return;
        }

        protected onBuyBtnClickhandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._itemData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.DramaLotteryGoBuyItem, {"nameTx": this._nameLabel.htmlText, "nowPrice": _newPrice, "index": _index}));
            }
            return;
        }

        /* internal */ /* var */_luckTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_itemBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameLabel: GLabel;

        /* internal */ /* var */_propItem: BaseItem;

        /* internal */ /* var */_oPriceLabel: GLabel;

        /* internal */ /* var */_pPriceLabel: GLabel;

        /* internal */ /* var */_oPriceNumLabel: GLabel;

        /* internal */ /* var */_pPriceNumLabel: GLabel;

        /* internal */ /* var */_oIngot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_pIngot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_buyBtn: GButton;

        /* internal */ /* var */_redLine: Object /* flash.display.Shape */;

        protected /* var */_selectLine: Object /* flash.display.Sprite */;

        /* internal */ /* var */_itemCode: int;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_newPrice: int;

        /* internal */ /* var */_oldPrice: int;

        /* internal */ /* var */_category: int;

        /* internal */ /* var */_swfPlayer: SWFPlayer;

        /* internal */ /* var */_debugShow: Object /* flash.text.TextField */;
    }
